class Student1{
    private String name;
    private int age;
    private String degree;
    public Student1(String name, int age, String degree) {
        super();//Java的规定：子类继承父类，子类的构造方法必须调用
        //super（）即父类的构造方法，而且必须放在构造方法的第一行
        this.name = name;
        this.age = age;
        this.degree = degree;
    }
    public Student1() {
        super();
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getDegree() {
        return degree;
    }
    public void setDegree(String degree) {
        this.degree = degree;
    }
    public void show(){
        System.out.println("姓名：" + this.getName() + " 年龄：" + this.getAge() + " 学位：" + this.getDegree() );
    }
}

class Undergraduate extends Student1{ //本科类
    private String specialty;//专业
    public String getSpecialty() {
        return specialty;
    }
    public void setSpecialty(String specialty) {
        this.specialty = specialty;
    }
    public Undergraduate(String name, int age, String degree, String specialty) {
        super(name, age, degree);
        this.specialty = specialty;
    }

    public void show(){
        System.out.println("姓名：" + this.getName() + "  年龄：" + this.getAge() + "  学位：" + this.getDegree() + "  专业：" + this.getSpecialty());
    }
}

class Graduate extends Student1{ //研究生类
    private String direction;
    public String getDirection() {
        return direction;
    }
    public void setDirection(String direction) {
        this.direction = direction;
    }
    public Graduate(String name, int age, String degree, String direction) {
        super(name, age, degree);
        this.direction = direction;
    }

    public void show(){
        System.out.println("姓名：" + this.getName() + "  年龄：" + this.getAge() + "  学位：" + this.getDegree() + "  研究方向：" + this.getDirection());
    }
}

public class student {
    public static void main(String[] args) {
        Undergraduate stu1=new Undergraduate("张三",20,"本科","通信");
        Graduate stu2=new Graduate("王五",25,"硕士","通信");
        stu1.show();
        stu2.show();

    }
}
